<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // await必须卸载async函数中 单向依赖
        // await右侧的表达式一般为promise对象
        // await返回的是promise成功的值
        // await的promise失败了，就会抛出异常，需要通过try...catch捕获处理



    const p =new Promise((resolve,reject)=>{
        // resolve('获取数据');
        reject('失败了');
    });

    async function main(){
        try{
            let result = await p;
        console.log(result);}catch(e){
            console.log(e);
        }
        
    }

    main();


    </script>
</body>
</html>